﻿///////////////////////////////////////////////////////
//
// XDesigner.ORM 
//
// autohr : yuans
//
// date: 2011-2-23
//
// email  : yyf9989@hotmail.com
// 
//
///////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel ;

namespace XDesigner.ORM.DOM
{
    [Serializable()]
    public class ORMDictionaryInfo
    {
        public ORMDictionaryInfo()
        {
        }

        private string _Name = null;
        [DefaultValue(null)]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        private string _CommandText = null;
        [DefaultValue(null)]
        public string CommandText
        {
            get { return _CommandText; }
            set { _CommandText = value; }
        }

        private string _ValueFieldName = null;
        [DefaultValue(null)]
        public string ValueFieldName
        {
            get { return _ValueFieldName; }
            set { _ValueFieldName = value; }
        }

        private string _TextFieldName = null;
        [DefaultValue(null)]
        public string TextFieldName
        {
            get { return _TextFieldName; }
            set { _TextFieldName = value; }
        }
    }

    public class ORMDictionaryInfoList : System.Collections.CollectionBase
    {
        public ORMDictionaryInfoList()
        {
        }

        public ORMDictionaryInfo this[int index]
        {
            get
            {
                return (ORMDictionaryInfo)this.List[index];
            }
        }

        public ORMDictionaryInfo this[string name]
        {
            get
            {
                foreach (ORMDictionaryInfo item in this)
                {
                    if (string.Compare(name, item.Name, true) == 0)
                    {
                        return item;
                    }
                }
                return null;
            }
        }

        public int Add(ORMDictionaryInfo item)
        {
            return this.List.Add(item);
        }

        public void Remove(ORMDictionaryInfo item)
        {
            this.List.Remove(item);
        }
    }
}
